/**
 * <b>项目名：</b>ht-web<br/>  
 * <b>包名：</b>com.flea.hclv.service.impl<br/>  
 * <b>文件名：</b>FaceInfoServiceImpl.java<br/>  
 * <b>版本信息：</b>1.0<br/>  
 * <b>日期：</b>2019年8月22日 上午10:21:08<br/>  
 * <b>COPYRIGHT 2010-2012 ALL RIGHTS RESERVED 虫子科技</b>-版权所有<br/>
 */
package com.flea.hclv.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.flea.hclv.model.dao.FaceInfoMapper;
import com.flea.hclv.model.entity.vo.FaceInfoPersonVo;
import com.flea.hclv.service.FaceInfoService;
import com.flea.hclv.util.HclvDictUtil;
import com.flea.hclv.util.ServerResponse;
import com.flea.system.base.util.StringUtil;
import com.flea.system.bean.FleaPage;
import com.flea.system.entity.WebDict;

/**	
 * @description TODO
 * @createTime 2019年8月22日 上午10:21:08
 * @modifyTime
 * @author myflea@163.com
 * @version 1.0
 */
@Service
public class FaceInfoServiceImpl implements FaceInfoService {
	@Autowired
	private FaceInfoMapper faceInfoMapper;

	@Override
	public ServerResponse<FleaPage<FaceInfoPersonVo>> selectAll(int curPage,
			int pageSize, String personName,String projectCode,String teamCode,String startTime ,String endTime) {
		RowBounds rowBounds = new RowBounds(curPage, pageSize);
		List<FaceInfoPersonVo> list = faceInfoMapper.selectAll(rowBounds, personName,projectCode,teamCode,startTime,endTime);
		FleaPage<FaceInfoPersonVo> p = new FleaPage<>(list);
		p.setCurPageData(coverCodeToName(p.getCurPageData()));
		return ServerResponse.createBySuccess(p);
	}
	private List<FaceInfoPersonVo> coverCodeToName(List<FaceInfoPersonVo> list){
		List<FaceInfoPersonVo> nlist = new ArrayList<>();
		List<WebDict> workerTypes =  HclvDictUtil.getDictWorkType();
		List<WebDict> projects = HclvDictUtil.getHTProjectList();
		List<WebDict> teams = HclvDictUtil.getTeams();
		
		for (FaceInfoPersonVo fb : list) {
			
			for (WebDict webDict : workerTypes) {
				if(webDict.getDictCode().equals(fb.getWorkerType())) {
					fb.setWorkerName(webDict.getDictName());
					break;
				}
				
			}
		
				String code = fb.getProjectCode();
				String projectName = "";
				
				for (WebDict webDict : projects) {
					if(webDict.getDictCode().equals(code)) {
						projectName=webDict.getDictName();
					}
				}
//				if(!StringUtil.isEmpty(codes)) {
//					
//					String[] code = codes.split(",");
//					
//					for (int i = 0; i < code.length; i++) {
//						for (WebDict webDict : projects) {
//							if(webDict.getDictCode().equals(code[i])) {
//								projectNames+=webDict.getDictName();
//								projectNames+=";";
//							}
//						}
//					if(!StringUtil.isEmpty(projectNames)) {
//						projectNames=projectNames.substring(0,projectNames.length()-1);
//					}
//				}
//				
				fb.setProjectName(projectName);
//				
//			}
			for (WebDict webDict : teams) {
				if(webDict.getDictCode().equals(fb.getTeam())) {
					fb.setTeamName(webDict.getDictName());
					break;
				}
			}
			nlist.add(fb);
			
		}
		
		
		
		
		
		
		
		
		return nlist;
	}
	
	

}
